﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Windows;
using SoftSource.Common;
using SoftSource.Timecard.ViewModelInterfaces;
using SoftSource.Timecard.Web.Data;
using SoftSource.Reactive;

namespace SoftSource.Timecard.ViewModels
{
    public sealed class UpdateReminderViewModel : IUpdateReminderViewModel
    {
        public UpdateReminderViewModel()
        {
            this.Entries = new ObservableProperty<IEnumerable<LastEntry>>();
        }

        #region IUpdateReminderViewModelConsume Members

        public IObservableProperty<IEnumerable<LastEntry>> Entries { get; private set; }

        private IEnumerable<LastEntry> entrySource;
        public IEnumerable<LastEntry> EntrySource
        {
            get { return this.entrySource; }
            set
            {
                this.entrySource = value;
                this.Entries.Value = this.entrySource;
            }
        }

        public Func<string, IEnumerable<int>, string, IObservable<Unit>> SendReminders { get; set; }
        public Func<Action<IObservable<string>>, UIElement> CreateGetUserPasswordView { get; set; }

        public IObservable<Unit> Load { get; set; }

        #endregion

        #region INotifyPropertyChanged Members        

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region IDisposable Members

        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }

        #endregion

        ~UpdateReminderViewModel()
        {
            this.Dispose();
        }
    }
}
